﻿@using SmartStore.Rules
@using SmartStore.Admin.Models.Rules
@model RuleSetModel
@{
    ViewBag.Title = string.Concat(T("Admin.Rules.EditRule"), " - ", Model.Name);
}

@using (Html.BeginForm())
{
    <div class="section-header">
        <div class="title">
            @ViewBag.Title @Html.ActionLink("(" + @T("Admin.Common.BackToList") + ")", "List")
        </div>
        <div class="options">
			@if (Model.Id != 0 && (Model.Scope == RuleScope.Customer || Model.Scope == RuleScope.Product))
			{
				<a id="btn-preview-ruleset" href="@Url.Action("Preview", new { id = Model.Id })" class="btn btn-secondary">
					<i class="far fa-eye"></i>
					<span>@T("Admin.Common.Preview")</span>
				</a>
			}
            <button type="submit" name="save" value="save" class="btn btn-warning">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.Save")</span>
            </button>
            <button type="submit" name="save" value="save-continue" class="btn btn-secondary">
                <span>@T("Admin.Common.SaveContinue")</span>
            </button>
            <button type="submit" id="rule-delete" name="rule-delete" class="btn btn-danger">
                <i class="far fa-trash-alt"></i>
                <span>@T("Admin.Common.Delete")</span>
            </button>
        </div>
    </div>

    Html.RenderPartial("_CreateOrUpdate", Model);
}
@Html.DeleteConfirmation("rule-delete")

<script>
	$(function () {
		$('#btn-preview-ruleset').on('click', function (e) {
			e.preventDefault();
			openPopup($(this).attr('href'), true /* large */, true /* flex */);
			return false;
		});
	});
</script>